package sz.szsmk.citizencard.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;
import android.widget.Toast;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.layout.DefaultLayoutHelper;
import com.chenenyu.router.annotation.Route;
import com.orhanobut.hawk.Hawk;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.HomeFragmentBinding;
import sz.szsmk.citizencard.dialog.TwoButtonDialog;
import sz.szsmk.citizencard.ioc.Compontent.DaggerCommonFragmentComponent;
import sz.szsmk.citizencard.log.L;
import sz.szsmk.citizencard.model.network.bean.response.BaseBean;
import sz.szsmk.citizencard.model.network.bean.response.CloudFlashRes;
import sz.szsmk.citizencard.model.network.bean.response.GetOrderOpenidRes;
import sz.szsmk.citizencard.model.network.bean.response.GetUrlRes;
import sz.szsmk.citizencard.model.network.bean.response.HomeAllfunResponse;
import sz.szsmk.citizencard.model.network.bean.response.HomeHeadFuncResponse;
import sz.szsmk.citizencard.model.network.bean.response.HomeWeathRes;
import sz.szsmk.citizencard.model.network.bean.response.IUserInfo;
import sz.szsmk.citizencard.model.network.bean.response.OneWordRes;
import sz.szsmk.citizencard.model.network.bean.response.QueryCitizenCardRes;
import sz.szsmk.citizencard.model.network.bean.response.QueryPageAdresponse;
import sz.szsmk.citizencard.model.network.bean.response.QueryPageResourceRes;
import sz.szsmk.citizencard.model.network.bean.response.QueryUserCardResponse;
import sz.szsmk.citizencard.model.network.bean.response.SeleciUserAuthRes;
import sz.szsmk.citizencard.model.network.bean.response.SplashResponse;
import sz.szsmk.citizencard.model.network.dzbean.res.MessageEvent;
import sz.szsmk.citizencard.mvp.contract.IHomeContact;
import sz.szsmk.citizencard.mvp.presenter.HomePresenter;
import sz.szsmk.citizencard.ui.activity.IMainActivity;
import sz.szsmk.citizencard.ui.activity.RoutineCardDetailActivity;
import sz.szsmk.citizencard.ui.activity.YouzanActivity;
import sz.szsmk.citizencard.ui.adapter.BannerAdapter;
import sz.szsmk.citizencard.ui.adapter.HomeAdaverAdapter;
import sz.szsmk.citizencard.ui.adapter.HomeHotDotAdapter;
import sz.szsmk.citizencard.ui.adapter.HorizontalAdapter;
import sz.szsmk.citizencard.ui.adapter.WeatherAdapter;
import sz.szsmk.citizencard.ui.base.IBaseFragment;
import sz.szsmk.citizencard.util.ACache;
import sz.szsmk.citizencard.util.ButtonUtils;
import sz.szsmk.citizencard.util.Constant;
import sz.szsmk.citizencard.util.JumpUtils;
import sz.szsmk.citizencard.util.PubUtils;

@Route("homefragment")
public class HomeFragment extends IBaseFragment<HomePresenter, HomeFragmentBinding>
        implements IHomeContact.IHomeView {
    private String mTitle;
    private RecyclerView mainView;

    /**
     * vlayout布局适配器
     */

    private List<DelegateAdapter.Adapter> adapters;
    private HorizontalAdapter horizontalAdapter;
    private String access_token;
    private WeatherAdapter weatherAdapter;
    private HomeHotDotAdapter homeHotAdapter;
    private BannerAdapter bannerAdapter;
    private HomeAdaverAdapter homeAdaverAdapter;

    private DelegateAdapter delegateAdapter;

    private int theFirst = 0;
    private List<HomeHeadFuncResponse.FunctionListBean> headList;

    public static HomeFragment getInstance() {
        HomeFragment homeFragment = new HomeFragment();
        return homeFragment;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.home_fragment;
    }

    @Override
    public void onResume() {
        super.onResume();
//        mPresenter.getUrl();
        access_token = ACache.get(DaggerApplication.getIns()).getAsString("access_token");
        Constant.isBind = false;
        try {
            theFirst = (int) ACache.get(getActivity()).getAsObject(RoutineCardDetailActivity.FIRST_CARD_KEY);
        } catch (Exception e) {
            theFirst = 0;
        }

        dataBinding.mainView.post(new Runnable() {
            @Override
            public void run() {
                if (access_token != null) {
                    mPresenter.getGetOrderId("", access_token);
                    mPresenter.getUserInfo();
                }
                mPresenter.queryHeadFunc();
                mPresenter.queryMainAd();
                mPresenter.queryPageAd();
                mPresenter.recordUserFunc();
                mPresenter.queryUserCard();
            }
        });

    }

    @Override
    protected void initInjector() {
        DaggerCommonFragmentComponent.builder().appCompontent(DaggerApplication.getAppComponent())
                .build().inject(this);
    }

    @Override
    protected void initViews() {
        mainView = dataBinding.mainView;
        initLayout();
    }


    /**
     * 初始化vlayout
     */
    private void initLayout() {
        VirtualLayoutManager layoutManager = new VirtualLayoutManager(getActivity()) {
            @Override
            public boolean canScrollVertically() {
                return true;
            }
        };
        mainView.setLayoutManager(layoutManager);
        mainView.setNestedScrollingEnabled(false);
        //解决数据加载不完的问题
//        mainView.setNestedScrollingEnabled(false);
        mainView.setHasFixedSize(true);
        RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
        mainView.setRecycledViewPool(viewPool);
        viewPool.setMaxRecycledViews(0, 30);
        delegateAdapter = new DelegateAdapter(layoutManager, true);
        mainView.setAdapter(delegateAdapter);
        adapters = new LinkedList<>();

        mainView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                weatherAdapter.invalidateData();
            }
        });

        //温度 城市   头部（充值，余额查询，服务网点，扫码乘车）适配器
        DefaultLayoutHelper weatherHelper = new DefaultLayoutHelper();
//        weatherHelper.setPadding(10, 10, 10, 11);
        weatherAdapter = new WeatherAdapter(getActivity(), weatherHelper, dataBinding.backView);
        weatherAdapter.addCardOnClick(new WeatherAdapter.HomeAddCardInferface() {
            @Override
            public void onClick(View view, int position) {
                if(headList!=null){

                    HomeHeadFuncResponse.FunctionListBean functionListBean = headList.get(position);
                    String url = functionListBean.getLink_url();
                    String sys_label = functionListBean.getSys_label();
                    int need_header = functionListBean.getNeed_header();
                    int function_id = functionListBean.getFunction_id();
                    int modularId = functionListBean.getModularId();
                    //埋点
                    mPresenter.userBehaviorBrowse(modularId);
                    toJumpView(url, function_id, sys_label, need_header);
                }
            }
        });
        adapters.add(weatherAdapter);

        horizontalAdapter = new HorizontalAdapter(getActivity(), new DefaultLayoutHelper());
        horizontalAdapter.setBaseInterface(new HorizontalAdapter.BaseInterface() {
            @Override
            public void onClick(View view, String url, String sys_label, int need_header, int id,int modularId) {
                //埋点
                mPresenter.userBehaviorBrowse(modularId);
                //横向滑动
                toJumpView(url, id, sys_label, need_header);
            }
        });
        adapters.add(horizontalAdapter);
        //轮播图广告适配器
        DefaultLayoutHelper bannerLayouHelper = new DefaultLayoutHelper();
        bannerAdapter = new BannerAdapter(DaggerApplication.getIns(), bannerLayouHelper);
        bannerAdapter.setBaseInterface(new BannerAdapter.BaseInterface() {
            @Override
            public void onClick(View view, String url, String syslabl, int needHeader, int id,int modularid) {
                //埋点
                mPresenter.userBehaviorBrowse(modularid);
                toJumpView(url, id, syslabl, needHeader);
            }
        });
        adapters.add(bannerAdapter);

        //热销适配器
        DefaultLayoutHelper hotSaleHelper = new DefaultLayoutHelper();
        homeHotAdapter = new HomeHotDotAdapter(DaggerApplication.getIns(), hotSaleHelper);
        homeHotAdapter.setBaseInterface(new HomeHotDotAdapter.BaseInterface() {
            @Override
            public void onClick(View view, String url, String syslabl, int needHeader, int resource_id,int modularId) {
                //埋点
                mPresenter.userBehaviorBrowse(modularId);
                toJumpView(url, resource_id, syslabl, needHeader);
            }
        });
        adapters.add(homeHotAdapter);

        //首页广告适配器
        DefaultLayoutHelper adavweHelper = new DefaultLayoutHelper();
        homeAdaverAdapter = new HomeAdaverAdapter(getActivity(), adavweHelper);
        homeAdaverAdapter.setBaseInterface(new HomeAdaverAdapter.BaseInterface() {
            @Override
            public void onClick(View view, String url, String syslabl, int needHeader, int resource_id,int modularid) {
                //埋点
                mPresenter.userBehaviorBrowse(modularid);
                toJumpView(url, resource_id, syslabl, needHeader);
            }
        });
        adapters.add(homeAdaverAdapter);

        delegateAdapter.setAdapters(adapters);
        delegateAdapter.notifyDataSetChanged();
    }


    private void toJumpView(String url, int id, String sys_label, int need_header) {
        if (url == null) {
            return;
        }
        if (url.equals("citizenCard")) {
//            Bundle bundle = new Bundle();
//            JumpUtils.gotoNeedGesture(mContext, "elecCitizenCard", bundle);
            if (ButtonUtils.isFastClick()) {
                ((IMainActivity) mContext).getmPresenter().getOpenId();
            }

        } else if (url.equals("proto:direct_bank")) {

            if (access_token == null) {
                toLogin();
            }else{
                mPresenter.getUrl();
            }

        } else if (url.equals("proto:bus")) {
            JumpUtils.jump(mContext, "BusHomeActivity", 0);
        } else if (url.equals("proto:add_cards")) {
            if (access_token == null) {
                toLogin();
            }else{
                ((IMainActivity) getActivity()).queryUserCard("home");
            }
        } else if (url.equals("proto:fund")) {
            //公积金
            mPresenter.selectUserAuth("gjj");

        } else if (url.equals("proto:consumer_business")) {
            //商家消费
            JumpUtils.jump(mContext, "business", 0);
        } else if (url.equals("proto:social")) {

            mPresenter.selectUserAuth("sb");

        } else if (url.equals("proto:osmanthus")) {

            mPresenter.selectUserAuth("ghf");

        } else if (url.equals("proto:subway")) {
            JumpUtils.jump(mContext, "SubwayHomeActivity", 0);

        } else if (url.equals("proto:balance_inquiry")) {
            //余额查询
            JumpUtils.jump(mContext, "querybalance", 0);

        } else if (url.equals("proto:service_network")) {
            //服务网点
            JumpUtils.jump(mContext, "nerwork", 0);

        } else if (url.equals("proto:citizenCard_charge")) {
            //云闪充
            if (access_token == null) {
                toLogin();
            }else{
                mPresenter.checkSuccessOrderStatus(access_token);
            }

        } else if(url.equals("proto:finance")){
            MessageEvent message = new MessageEvent(MessageEvent.CODE_OPENNG);

            EventBus.getDefault().post(message);
        } else {
            if (access_token == null) {
                toLogin();
            } else {
                /**
                 * sys_label参数判断逻辑
                 * 1.sys_label为null  或者sys_label 为"";不用管 直接跳转
                 * 2.sys_label为NOHEADER 拼接access_token
                 * 3.sys_label不为空，且不为NOHEADER，调张旺接口
                 */
                L.e(Constant.TITLE, "url--" + url + "----syslabel---" + sys_label);
                if (url == null || url.trim().equals("")) {
                    return;
                }
                Bundle bundle = new Bundle();
                if (need_header == 1) {
                    bundle.putString(Constant.TITLE, "");
                }
                if (sys_label != null && sys_label.equals("NOHEADER")) {
                    bundle.putString("url", url + "?access_token=" + access_token);
                    JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
                } else if (sys_label != null && sys_label.equals("HUIMIN")) {
                    if (url.contains("?")) {
                        bundle.putString("url", url + "&" + Constant.EXTENT);
                    } else {
                        bundle.putString("url", url + "?" + Constant.EXTENT);
                    }
                    //苏体通需要自定义ua 传递标识
                    bundle.putString("stt", "stt");
                    JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
                } else if (sys_label != null && sys_label.equals("ZZK")) {
                    bundle.putString("url", url + "?access_token=" + access_token);
                    JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
                } else if (sys_label != null && sys_label.length() == 0) {
                    bundle.putString("url", url);
                    JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
                } else if (sys_label == null) {
                    if (url.contains("youzan")) {
                        ACache.get(DaggerApplication.getIns()).remove("sykt");
                        ACache.get(DaggerApplication.getIns()).put("sykt", "sykt");

                        Intent intent = new Intent(getActivity(), YouzanActivity.class);
                        intent.putExtra(YouzanActivity.KEY_URL, url);
                        startActivity(intent);
                    } else {
                        bundle.putString("url", url);
                        JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
                    }
                }
            }
        }
    }

    private void toLogin() {
        JumpUtils.jump(mContext, "login", 0);
    }

    @Override
    protected void updateViews() {


        if (Hawk.contains("weather_res")) {
            HomeWeathRes response = Hawk.get("weather_res");
            weatherAdapter.setHomeWeath(response);
        }

        if (Hawk.contains("one_word")) {
            OneWordRes response = Hawk.get("one_word");
            weatherAdapter.setOneWordData(response);
        }

        //市民卡 头部  网络请求
        if (Hawk.contains("head_fun")) {
            HomeHeadFuncResponse response = Hawk.get("head_fun");
            if (response != null) {
                weatherAdapter.setFunctionListBeanList(response.getFunction_list());
            }
        }

        weatherAdapter.setCardData(new ArrayList<>());

        weatherAdapter.notifyDataSetChanged();

        if (Hawk.contains("all_fun_data")) {
            HomeAllfunResponse response = Hawk.get("all_fun_data");
            if (response != null) {

                horizontalAdapter.setAppData(response.getFunction_list());
                List<HomeAllfunResponse.FunctionListBean> list = response.getFunction_list();
                for (HomeAllfunResponse.FunctionListBean bean : list)
                    bean.setFunction_id(-1);
                horizontalAdapter.notifyDataSetChanged();
            }
        }

        if (Hawk.contains("home_ad_2")) {
            QueryPageResourceRes response = Hawk.get("home_ad_2");
            if (response != null) {

                List<QueryPageResourceRes.ResourceListBean> list = response.getResource_list();
                for (QueryPageResourceRes.ResourceListBean bean : list)
                    bean.setLink_url("");
                bannerAdapter.setViewData(response);
            }
        }

        if (Hawk.contains("home_ad_3")) {
//            读取本地链接的情况下删除链接
            QueryPageResourceRes response = Hawk.get("home_ad_3");
            if (response != null) {

                List<QueryPageResourceRes.ResourceListBean> list = response.getResource_list();
                for (QueryPageResourceRes.ResourceListBean bean : list)
                    bean.setLink_url("");
                homeHotAdapter.setViewData(response);
            }
        }

        if (Hawk.contains("home_ad_4")) {
            QueryPageResourceRes response = Hawk.get("home_ad_4");
            if (response != null) {

                List<QueryPageResourceRes.ResourceListBean> list = response.getResource_list();
                for (QueryPageResourceRes.ResourceListBean bean : list)
                    bean.setLink_url("");
                homeAdaverAdapter.setViewData(response);
            }
        }
        dataBinding.mainView.post(new Runnable() {
            @Override
            public void run() {
                mPresenter.getWeathGeneral();
                mPresenter.queryAllFunc();
                mPresenter.queryOneWordAd();
                mPresenter.queryPageResource(2);
                mPresenter.queryPageResource(3);
                mPresenter.queryPageResource(4);
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void updataError(BaseBean res) {
        Toast.makeText(mActivity, res.getMessage(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void getUserInfoSucc() {

    }

    @Override
    public void queryOneWordAdSucc(OneWordRes response) {
        if (response != null) {
            weatherAdapter.setOneWordData(response);
            Hawk.delete("one_word");
            Hawk.put("one_word", response);
        }
    }

    @Override
    public void queryPageResourceSucc(QueryPageResourceRes response, int area_id) {
        if (response != null) {

            if (area_id == 3) {
                Hawk.delete("home_ad_3");
                Hawk.put("home_ad_3", response);
                homeHotAdapter.setViewData(response);
            }
            if (area_id == 2) {
                Hawk.delete("home_ad_2");
                Hawk.put("home_ad_2", response);
                bannerAdapter.setViewData(response);
            }
            if (area_id == 4) {
                Hawk.delete("home_ad_4");
                Hawk.put("home_ad_4", response);
                homeAdaverAdapter.setViewData(response);
            }
        }
    }

    @Override
    public void queryPageResourceFail() {

    }

    @Override
    public void queryOneWordAdFail() {

    }

    @Override
    public void checkSuccessOrderStatusSucc(String orderStatus) {

        if (orderStatus != null) {
            if (orderStatus.equals("1")) {
                Bundle bundle = new Bundle();
                bundle.putString("url", Constant.BASE_URL + "app-front-end/#/charge/main?access_token=" + access_token);
                JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
            } else if (orderStatus.equals("0")) {
                Bundle bundle = new Bundle();
                bundle.putString("url", Constant.BASE_URL + "app-front-end/#/charge/guide?access_token=" + access_token);
                JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);

            }
        }
    }

    @Override
    public void checkSuccessOrderStatusFail(CloudFlashRes cloudFlashRes) {
        PubUtils.popTipOrWarn(getActivity(), cloudFlashRes.getMessage());
    }

    @Override
    public void queryAllFuncSucc(HomeAllfunResponse response) {

        setAllFunData(response);
    }

    private void setAllFunData(HomeAllfunResponse response) {
        if (response != null) {
            List<HomeAllfunResponse.FunctionListBean> function_list = response.getFunction_list();
            horizontalAdapter.setAppData(function_list);
            Hawk.delete("all_fun_data");
            Hawk.put("all_fun_data", response);
            horizontalAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void queryHeadFuncSucc(HomeHeadFuncResponse response) {
        headList = response.getFunction_list();
        weatherAdapter.setFunctionListBeanList(headList);
        Hawk.delete("head_fun");
        Hawk.put("head_fun", response);
        weatherAdapter.notifyDataSetChanged();
    }

    @Override
    public void queryMainAdSucc(SplashResponse response) {

    }

    @Override
    public void queryPageAdSucc(QueryPageAdresponse response) {

    }

    @Override
    public void queryUserCardSucc(QueryUserCardResponse response) {
        List<QueryUserCardResponse.DataBean> data = response.getData();
        weatherAdapter.setCardData(data);
        weatherAdapter.notifyDataSetChanged();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                weatherAdapter.setFirstCard(theFirst);
            }
        }, 500);
    }

    @Override
    public void queryUserCardFail(String message) {
        weatherAdapter.setCardData(new ArrayList<>());
        weatherAdapter.notifyDataSetChanged();
    }

    @Override
    public void getTokenSucc() {

    }

    @Override
    public void getTokenFail() {

    }

    @Override
    public void getWeathGeneralSucc(HomeWeathRes response) {
        if (response != null) {
            weatherAdapter.setHomeWeath(response);
            Hawk.delete("weather_res");
            Hawk.put("weather_res", response);
            weatherAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void getWeathGeneralFail() {

    }

    @Override
    public void getUserInfoSucc(IUserInfo response) {

    }

    @Override
    public void getUserInfoFail(IUserInfo response) {
        String code = response.getCode();
        if (code.equals("000016")) {
            final TwoButtonDialog dialog = new TwoButtonDialog(getActivity(), response.getMessage());

            dialog.setOnOkClickListener(new TwoButtonDialog.OnOkClickListener() {
                @Override
                public void onOkClick() {
                    ACache.get(getActivity()).remove(" ");
                    dialog.cancel();
                }
            });
            dialog.setOnCancelClickListener(new TwoButtonDialog.OnCancelClickListener() {
                @Override
                public void onCancelClick() {
                    ACache.get(getActivity()).remove("access_token");
                    ACache.get(getActivity()).remove("mextend");
                    JumpUtils.jump(mContext, "login", 0);
                    dialog.cancel();
//                    getActivity().finish();
                }
            });
            dialog.show();
        }
    }

    @Override
    public void getUrlSucc(GetUrlRes response) {
        String url = response.getUrl();
        Bundle bundle = new Bundle();
        bundle.putString(Constant.TITLE, "");
        bundle.putString("url", url);
        JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
    }

    @Override
    public void getUrlFail(GetUrlRes response) {

    }

    @Override
    public void selectUserAuthFail() {

    }

    @Override
    public void selectUserAuthSucc(SeleciUserAuthRes response, String type) {
        String access_token = ACache.get(getActivity()).getAsString("access_token");
        List<SeleciUserAuthRes.AuthTypeListBean> authTypeList = response.getAuthTypeList();

        if (type.equals("gjj")) {
            String isAuth = authTypeList.get(1).getIsAuth();
            //0未授权，1已授权，2未实名(L3认证)
            if (isAuth.equals("2")) {
                JumpUtils.jump(getActivity(), "RealNameActivity", 0);
            } else if (isAuth.equals("1")) {
                //跳转公积金
                Bundle bundle = new Bundle();
                String path = Constant.BASE_URL + "app-front-end/#/fund/main?access_token=" + access_token;
                bundle.putString("url", path);
                bundle.putString(Constant.CUST_NAME, Constant.USER_NAME);
                JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
            } else if (isAuth.equals("0")) {
                Bundle bundle = new Bundle();
                bundle.putString(Constant.TYPE, "gjj");
                String custName = Constant.USER_NAME;
                bundle.putString(Constant.ID_NAME, custName);
                JumpUtils.jumptoNatvie(getActivity(), "applicationAuthorActivity", 0, bundle);
            }

        }

        if (type.equals("sb")) {
            String isAuth = authTypeList.get(0).getIsAuth();
            //0未授权，1已授权，2未实名(L3认证)
            if (isAuth.equals("2")) {
                JumpUtils.jump(getActivity(), "RealNameActivity", 0);
            } else if (isAuth.equals("1")) {
                //跳转社保
                Bundle bundle = new Bundle();
                String path = Constant.BASE_URL + "app-front-end/#/social/main?access_token=" + access_token;
                bundle.putString("url", path);
                JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
            } else if (isAuth.equals("0")) {
//                String url = Constant.BASE_URL + "fundAndSociety/authPage?access_token" + access_token + "&type=0&name=" + custName;
                Bundle bundle = new Bundle();
//                bundle.putString("url", url);
                bundle.putString(Constant.TITLE, "桂花分");
                JumpUtils.jumptoNatvie(getActivity(), "webView", 0, bundle);
            }

        }

        if (type.equals("ghf")) {
            String isAuth = authTypeList.get(2).getIsAuth();
            //0未授权，1已授权，2未实名(L3认证)
            if (isAuth.equals("2")) {
                JumpUtils.jump(getActivity(), "RealNameActivity", 0);
            } else if (isAuth.equals("1")) {
                mPresenter.getGetOrderId("ghf", "ghf");
            } else if (isAuth.equals("0")) {
                Bundle bundle = new Bundle();
                bundle.putString(Constant.TYPE, "ghf");
                bundle.putString(Constant.ID_NAME, Constant.USER_NAME);
                JumpUtils.jumptoNatvie(getActivity(), "applicationAuthorActivity", 0, bundle);
            }

        }
    }

    @Override
    public void getGetOrderIdSucc(GetOrderOpenidRes response, String type, String murl) {
        if (type.equals("ghf")) {
            //跳转桂花分
            String url = Constant.SZ_URL +"?"+ response.getExtend();
            Bundle bundle = new Bundle();
            bundle.putString("url", url);
            bundle.putString(Constant.TITLE, "桂花分");
            JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
        } else if (type.equals("tyhm")) {
            Bundle bundle = new Bundle();
            bundle.putString("url", murl);
            bundle.putString(Constant.TITLE, "桂花分");
            JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);
        }
    }

    @Override
    public void getGetOrderIdFail() {

    }

    @Override
    public void queryCitizenCardFail() {

    }

    @Override
    public void queryCitizenCardSucc(QueryCitizenCardRes response) {
        if (response.getCitizenCardInfoList() == null || response.getCitizenCardInfoList().size() == 0) {
            Bundle bundle = new Bundle();
            bundle.putString("key", "home");
            JumpUtils.jumptoNatvie(mContext, "addnewcard", 0, bundle);
        } else {
            Bundle bundle = new Bundle();
            bundle.putString("type", "3");
            JumpUtils.jumptoNatvie(mContext, "routinecarddetail", 0, bundle);
        }
    }


    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }
}